package com.bdqn.controller;

import com.alibaba.fastjson.JSONObject;
import com.bdqn.pojo.Grade;
import com.bdqn.service.GradeService;
import com.bdqn.util.LayData;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <Description> <br>
 *
 * @author tao<br>
 * @version 1.0<br>
 * @taskId: <br>
 * @createDate 2019/09/20 15:35 <br>
 * @see com.bdqn.controller <br>
 */
@Controller
@RequestMapping("/grade")
public class GradeController {

    @Resource
    private GradeService gradeService;

    @RequestMapping(value="/tograde",method = RequestMethod.GET)
    public String toUserList(Model model, HttpSession session){
        return "jsp/grade/list";
    }

    @RequestMapping(value="/list",method = RequestMethod.GET)
    @ResponseBody
    public String getUserList(Model model, HttpSession session){

        List<Grade> grades = gradeService.getAll();
        return JSONObject.toJSONString(grades);
    }

}
